/*
 * @Author: wuzhouhai wzh200x@126.com
 * @Date: 2024-08-08 14:15:08
 * @LastEditors: wuzhouhai wzh200x@126.com
 * @LastEditTime: 2024-08-09 10:45:22
 * @FilePath: \dwys_web\assets\script\phoenix\messageHandle\s2cActiveRoom_MessageHandle.ts
 * @Description: 
 */
import { oops } from "../../../../extensions/oops-plugin-framework/assets/core/Oops";
import { IMessageHandle } from "../../../../extensions/phoenix-plugin-client/assets/core/interface/IMessageHandle";
import messageManager from "../../../../extensions/phoenix-plugin-client/assets/core/managers/message.manager";
import { GameEvent } from "../../common/event/GameEvent";
import { OpcodeApp } from "../define/opcode.define";
import * as proto from "../protoc/ts/proto_app.js";

export default class S2CActiveRoom implements IMessageHandle{
    handleMessage(msgData: any): void {
        let response = msgData as proto.s2c_ActiveRoom;
        if (response.base?.code != 0) {
            oops.message.dispatchEvent(GameEvent.AddGameMsgInfo, "激活房间失败 " + response.base?.msg);
            return;
        }
        console.log("S2CActiveRoom active", response.roomInfo?.active);
        console.log("S2CGetRoomInfo", response);
        oops.message.dispatchEvent(GameEvent.UpdateRoom, response.roomInfo);
        oops.message.dispatchEvent(GameEvent.AddGameMsgInfo, "激活房间成功");
        oops.message.dispatchEvent(GameEvent.RequestGetRoomPmtInfo, response.roomInfo?.roomId, response.roomInfo?.active);
    }
}

messageManager.registerHandle(OpcodeApp.Opcode_SC_ACTIVE_ROOM, new S2CActiveRoom());